﻿<html>

<head>
    <meta charset="utf-8">

    <title>定制后台登录</title>
    <script src="./config/config.js"></script>
    <script src="./js/jquery-1.10.2.min.js"></script>
    <script src="./js/jquery.cookie.js"></script>
    <script src="./constant/common.js"></script>
    <script src="./constant/constant.js"></script>
    <script src="./js/prop-types.js"></script>
    <script src="./js/MD5.js"></script>
    <script src="./js/bootstrap.min.js"></script>
    <script src="./js/react/react.development.js"></script>
    <script src="./js/react/react-dom.development.js"></script>
    <script src="./js/vConsole.js"></script>
    <link href="./css/common.css" rel="stylesheet" type="text/css" />
    <link href="./css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="renderer" content="webkit" />
    <meta name="force-rendering" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="full-screen" content="yes" />
    <meta name="x5-fullscreen" content="true" />
    <meta name="360-fullscreen" content="true" />
    <meta name="screen-orientation" content="portrait" />
    <meta name="x5-orientation" content="portrait">
    <!--<meta name="browsermode" content="application">-->    <meta name="x5-page-mode" content="app">
    <style>
        .title {
            font-size: 18pt;
            margin-bottom: 5vh;
            flex-direction: column;
            margin-top: -80px;
        }

        .title p{
            font-size: 34px;
            font-weight: bold;
            
        }

        .input-group {
            margin-bottom: 3vh;
        }

        .alertarea {
            position: absolute;
            width: 100vw;
        }

        .btm.phone{
            bottom: 70px;
            font-size: 28px;
            font-weight: bold;
        }

        .btm {
            position: absolute;
            bottom: 30px;
            width: 100vw;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .register{
            margin-top: 20px;
        }
    </style>

</head>

<body>
    <!-- <div class='container'></div> -->

    <div class="alertarea">

    </div>

    <div class="global_center c">
        <div class="center title">
            <p class="p1">
                小泥鳅定制系统
            </p>
            <span>登陆后台</span>
            <!-- <a href="https://jianaijia.com/pdlapi/dwgfile/2023-10-16/2fc2f27b835d4dcda009ce541534ae2c.dwg">测试123</a> -->
        </div>
        <div class="input-group w40">
            <span class="input-group-addon">用户</span>
            <input placeholder="请输入用户名" type="text" class="name form-control" />
        </div>
        <div class="input-group w40">
            <span class="input-group-addon">密码</span>
            <input placeholder="请输入密码" type="password" class="pwd form-control" />
        </div>

        <div class="center">
            <button id='login' class="btn btn-primary w40">登录</button>
        </div>

        <div class="center register">
            <button id='register' class="btn btn-primary w40">注册</button>
        </div>
    </div>

    <div class="btm phone">
        服务电话：13559580055
    </div>
    <div class="btm">
        <a href="https://beian.miit.gov.cn/" id='beian'>闽ICP备18004609号-2</a>
    </div> 


</body>
<script>
 

    var name = '';
    var pwd = '';

    function gologin(){
        var name = $('.name').val() || "";
            var pwd = $('.pwd').val() || "";
            if (name.length == 0 || pwd.length == 0) {
                showAlert($('.alertarea'), '账号或密码错误。', 'alfail', 'danger')                                                                                                   
            } else {
                $('#alfail').hide();
                pwd = md5(pwd + Constant.SALT);
               // console.log('md5551', pwd);

                backlogin(name, pwd, succ => { 
                    
                    var data = JSON.parse(succ);
                    console.log('data',data);
                    if (data.issuccess == 1) {
                        $.cookie('token', data.Token);
                       // $.cookie('token', 'kJjOJgi0w7Nt8ozNOVbecvEPB1Wp4hLV');
                        $.cookie('id', data.id);
                        $.cookie('shopid', data.shopid);
                        $.cookie('company', data.company||'');
                        $.cookie('shopname', data.shopname);
                        $.cookie('permission', data.permission);
                        $.cookie('gysm', data.gysm);
                        $.cookie('deadline', data.deadline); 
                        // setalllist(res => {
                        // })
                       window.location.href = 'dz_main.html';
                    } else {
                        showAlert($('.alertarea'), data.msg, 'alfail', 'danger')
                    }
                })
            }

    }

  
 
    document.addEventListener('keydown', function(event) {
        if (event.key === 'Enter' || event.keyCode === 13) { // 判断是否是回车键
            gologin()
        }
    });


    $(document).ready(function () {



        $('#login').click(function () {
            gologin()
            // var name = $('.name').val() || "";
            // var pwd = $('.pwd').val() || "";
            // if (name.length == 0 || pwd.length == 0) {
            //     showAlert($('.alertarea'), '账号或密码错误。', 'alfail', 'danger')                                                                                                   
            // } else {
            //     $('#alfail').hide();
            //     pwd = md5(pwd + Constant.SALT);
            //    // console.log('md5551', pwd);

            //     backlogin(name, pwd, succ => { 
            //         console.log('backlogin');
            //         var data = JSON.parse(succ);
            //         if (data.issuccess == 1) {
            //             $.cookie('token', data.Token);
            //            // $.cookie('token', 'kJjOJgi0w7Nt8ozNOVbecvEPB1Wp4hLV');
            //             $.cookie('id', data.id);
            //             $.cookie('shopid', data.shopid);
            //             $.cookie('company', data.company);
            //             $.cookie('shopname', data.shopname);
            //             $.cookie('permission', data.permission);
            //             $.cookie('gysm', data.gysm);
            //             $.cookie('deadline', data.deadline); 
            //             // setalllist(res => {
            //             // })
            //            window.location.href = 'dz_main.html';
            //         } else {
            //             showAlert($('.alertarea'), data.msg, 'alfail', 'danger')
            //         }
            //     })
            // }
        })

         $('#register').click(function () {
                window.location.href='./register.html'
            
         })
    })

</script>

</html>